'use strict';

// Setting up route
angular.module('core').config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {

        // Home state routing
        $stateProvider
            .state('index', {
                url: '/index',
                views: {
                    '': {
                        templateUrl: 'modules/core/client/views/index.client.view.html',
                        controller: 'IndexController'
                    },
                    'sideMenu@index': {
                        templateUrl: 'modules/core/client/views/sideMenu.client.view.html',
                        controller: 'SideMenuController'
                    },
                    'navBar@index': {
                        templateUrl: 'modules/core/client/views/header.client.view.html',
                        controller: 'NavBarController'
                    }
                },
                access: {
                    requiredAuthentication: true
                }
            })
            .state('index.home', {
                url: '/home',
                templateUrl: 'modules/core/client/views/home.client.view.html',
                access: {
                    name: '首页',
                    requiredAuthentication: true
                },
                controller: 'HomeController'
            })
            .state('not-found', {
                url: '/not-found',
                templateUrl: 'modules/core/client/views/404.client.view.html',
                data: {
                    ignoreState: true
                }
            })
            .state('bad-request', {
                url: '/bad-request',
                templateUrl: 'modules/core/client/views/400.client.view.html',
                data: {
                    ignoreState: true
                }
            })
            .state('forbidden', {
                url: '/forbidden',
                templateUrl: 'modules/core/client/views/403.client.view.html',
                data: {
                    ignoreState: true
                }
            });

        $urlRouterProvider.otherwise('/index/home');
    }
]);
